package com.yuanzong.wuliu.controller.admin.system.user;

import com.yuanzong.wuliu.common.vo.ApiResult;
import com.yuanzong.wuliu.controller.admin.system.user.param.AdminSystemUserAddParam;
import com.yuanzong.wuliu.controller.admin.system.user.param.AdminSystemUserModifyPasswordParam;
import com.yuanzong.wuliu.controller.admin.system.user.param.AdminSystemUserPageParam;
import com.yuanzong.wuliu.controller.admin.system.user.param.AdminSystemUserRemoveParam;
import com.yuanzong.wuliu.service.admin.system.user.AdminSystemUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Api(tags = "管理端 - 系统用户")
@RequestMapping("/admin/system/user/systemUser")
@Slf4j
public class AdminSystemUserController {

    @Autowired
    private AdminSystemUserService adminSystemUserService;

    @ApiOperation("分页")
    @RequestMapping(value = "/page", method = {RequestMethod.POST})
    public ApiResult page(@RequestBody AdminSystemUserPageParam param) throws Exception {
        ApiResult result = adminSystemUserService.page(param);
        return result;
    }

    @ApiOperation("添加")
    @RequestMapping(value = "/add", method = {RequestMethod.POST})
    public ApiResult add(@Valid @RequestBody AdminSystemUserAddParam param) throws Exception {
        ApiResult result = adminSystemUserService.add(param);
        return result;
    }

    @ApiOperation("修改密码")
    @RequestMapping(value = "/modifyPassword", method = {RequestMethod.POST})
    public ApiResult modifyPassword(@RequestBody AdminSystemUserModifyPasswordParam param) throws Exception {
        ApiResult result = adminSystemUserService.modifyPassword(param);
        return result;
    }

    @ApiOperation("删除")
    @RequestMapping(value = "/remove", method = {RequestMethod.POST})
    public ApiResult remove(@RequestBody AdminSystemUserRemoveParam param) throws Exception{
        ApiResult result = adminSystemUserService.remove(param);
        return result;
    }
}
